package com.video.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.video.common.annotation.Log;
import com.video.common.core.controller.BaseController;
import com.video.common.core.domain.AjaxResult;
import com.video.common.enums.BusinessType;
import com.video.system.domain.VideoTeacherTitle;
import com.video.system.service.IVideoTeacherTitleService;
import com.video.common.utils.poi.ExcelUtil;
import com.video.common.core.page.TableDataInfo;

/**
 * 职称Controller
 * 
 * @author lyh
 * @date 2021-07-31
 */
@RestController
@RequestMapping("/system/title")
public class VideoTeacherTitleController extends BaseController
{
    @Autowired
    private IVideoTeacherTitleService videoTeacherTitleService;

    /**
     * 查询职称列表
     */
    @PreAuthorize("@ss.hasPermi('system:title:list')")
    @GetMapping("/list")
    public TableDataInfo list(VideoTeacherTitle videoTeacherTitle)
    {
        startPage();
        List<VideoTeacherTitle> list = videoTeacherTitleService.selectVideoTeacherTitleList(videoTeacherTitle);
        return getDataTable(list);
    }

    /**
     * 导出职称列表
     */
    @PreAuthorize("@ss.hasPermi('system:title:export')")
    @Log(title = "职称", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(VideoTeacherTitle videoTeacherTitle)
    {
        List<VideoTeacherTitle> list = videoTeacherTitleService.selectVideoTeacherTitleList(videoTeacherTitle);
        ExcelUtil<VideoTeacherTitle> util = new ExcelUtil<VideoTeacherTitle>(VideoTeacherTitle.class);
        return util.exportExcel(list, "职称数据");
    }

    /**
     * 获取职称详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:title:query')")
    @GetMapping(value = "/{titleId}")
    public AjaxResult getInfo(@PathVariable("titleId") Integer titleId)
    {
        return AjaxResult.success(videoTeacherTitleService.selectVideoTeacherTitleById(titleId));
    }

    /**
     * 新增职称
     */
    @PreAuthorize("@ss.hasPermi('system:title:add')")
    @Log(title = "职称", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VideoTeacherTitle videoTeacherTitle)
    {
        return toAjax(videoTeacherTitleService.insertVideoTeacherTitle(videoTeacherTitle));
    }

    /**
     * 修改职称
     */
    @PreAuthorize("@ss.hasPermi('system:title:edit')")
    @Log(title = "职称", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VideoTeacherTitle videoTeacherTitle)
    {
        return toAjax(videoTeacherTitleService.updateVideoTeacherTitle(videoTeacherTitle));
    }

    /**
     * 删除职称
     */
    @PreAuthorize("@ss.hasPermi('system:title:remove')")
    @Log(title = "职称", businessType = BusinessType.DELETE)
	@DeleteMapping("/{titleIds}")
    public AjaxResult remove(@PathVariable Integer[] titleIds)
    {
        return toAjax(videoTeacherTitleService.deleteVideoTeacherTitleByIds(titleIds));
    }
}
